<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    :mask-closable="false"
    switch-fullscreen
    :ok-button-props="{ class:{'jee-hidden': true} }"
    cancel-text="关闭"
    @ok="handleOk"
    @cancel="handleCancel"
  >
    <span slot="title">
      <li-select-mould v-model="model.id" style="width:40%;" :disabled="disableSubmit" :version-disabled="model.versionDisabled" @change="mouldChange" />
      <span>
        {{title}}
      </span>
    </span>
    <PerviewForm2 ref="realForm" :disabled="disableSubmit" normal @ok="submitCallback" />
  </j-modal>
</template>

<script>

import PerviewForm2 from './PerviewForm2'
import liSelectMould from '../../../components/liSelectMould'

export default {
  name: 'PerviewForm',
  components: {
    PerviewForm2,
    liSelectMould
  },
  data() {
    return {
      title: '操作',
      model: {},
      width: 700,
      visible: false,
      disableSubmit: false
    }
  },
  methods: {
    add() {
      this.visible = true
      this.$nextTick(() => {
        this.$refs.realForm.add()
      })
    },
    edit(record) {
      this.model = Object.assign({}, record)
      this.visible = true
      this.$nextTick(() => {
        this.$refs.realForm.edit(record)
      })
    },
    mouldChange(val) {
      this.model.id = val
      this.$refs.realForm.edit(this.model)
    },
    close() {
      this.$emit('close')
      this.visible = false
    },
    submitCallback() {
      this.$emit('ok')
      this.visible = false
    },
    handleOk() {
      this.$refs.realForm.submitForm()
    },
    handleCancel() {
      this.close()
    }
  }
}
</script>

<style lang="less" scoped>
</style>
